import { request } from '@/utils/request'
import type { ApiResponse } from '@/utils/request'

/**
 * 学院课程查询参数
 */
export interface CollegeCourseQuery {
  collegeId?: number
  courseCode?: string
  courseName?: string
  courseType?: string
  courseNature?: string
  isActive?: boolean
  pageNum: number
  pageSize: number
}

/**
 * 学院课程表单数据
 */
export interface CollegeCourseForm {
  id?: number
  collegeId: number
  collegeName?: string
  templateId?: number
  courseCode: string
  courseName: string
  courseNameEn?: string
  courseType: string
  courseNature?: string
  creditHours: number
  totalHours: number
  theoryHours?: number
  practiceHours?: number
  labHours?: number
  computerHours?: number
  weeklyHours?: number
  teachingWeeks?: number
  examMode?: string
  gradingMethod?: string
  teachingMode?: string
  teachingLanguage?: string
  textbook?: string
  referenceMaterials?: string
  prerequisiteCourses?: string
  syllabus?: string
  isActive?: boolean
  vocationalSkillRequirements?: string
  industryStandard?: string
  practicalTrainingHours?: number
  internshipRequirements?: string
}

/**
 * 学院课程详情
 */
export interface CollegeCourseInfo extends CollegeCourseForm {
  createdTime?: string
  updatedTime?: string
}

/**
 * 学院课程分页结果接口
 */
export interface CollegeCoursePageResult {
  records: CollegeCourseInfo[]
  total: number
  size: number
  current: number
  pages: number
}

/**
 * 获取学院课程列表
 * @param query 查询参数
 * @returns 分页结果
 */
export function listCollegeCourse(query: CollegeCourseQuery) {
  return request.post<ApiResponse<CollegeCoursePageResult>>('/api/school/college-course/list', query)
}

/**
 * 获取学院课程详情
 * @param id 课程ID
 * @returns 课程详情
 */
export function getCollegeCourse(id: number) {
  return request.get<ApiResponse<CollegeCourseInfo>>(`/api/school/college-course/${id}`)
}

/**
 * 新增学院课程
 * @param data 课程数据
 * @returns 新增结果
 */
export function addCollegeCourse(data: CollegeCourseForm) {
  return request.post<ApiResponse<boolean>>('/api/school/college-course', data)
}

/**
 * 修改学院课程
 * @param data 课程数据
 * @returns 修改结果
 */
export function updateCollegeCourse(data: CollegeCourseForm) {
  return request.put<ApiResponse<boolean>>('/api/school/college-course', data)
}

/**
 * 删除学院课程
 * @param id 课程ID
 * @returns 删除结果
 */
export function deleteCollegeCourse(id: number) {
  return request.delete<ApiResponse<boolean>>(`/api/school/college-course/${id}`)
}

/**
 * 批量删除学院课程
 * @param ids 课程ID数组
 * @returns 批量删除结果
 */
export function batchDeleteCollegeCourse(ids: number[]) {
  return request.delete<ApiResponse<boolean>>('/api/school/college-course/batch', ids)
}

/**
 * 获取课程类型选项
 * @returns 课程类型选项
 */
export function getCourseTypeOptions() {
  return [
    {
      value: '必修',
      label: '必修'
    },
    {
      value: '选修',
      label: '选修'
    },
    {
      value: '实践',
      label: '实践'
    }
  ]
}

/**
 * 获取课程性质选项
 * @returns 课程性质选项
 */
export function getCourseNatureOptions() {
  return [
    {
      value: '公共基础',
      label: '公共基础'
    },
    {
      value: '专业基础',
      label: '专业基础'
    },
    {
      value: '专业核心',
      label: '专业核心'
    },
    {
      value: '专业方向',
      label: '专业方向'
    }
  ]
}

/**
 * 获取考核方式选项
 * @returns 考核方式选项
 */
export function getExamModeOptions() {
  return [
    {
      value: '考试',
      label: '考试'
    },
    {
      value: '考查',
      label: '考查'
    }
  ]
}

/**
 * 获取教学模式选项
 * @returns 教学模式选项
 */
export function getTeachingModeOptions() {
  return [
    {
      value: '线下',
      label: '线下'
    },
    {
      value: '线上',
      label: '线上'
    },
    {
      value: '线下+线上',
      label: '线下+线上'
    }
  ]
} 